﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using NIIT.SaoBacDau.Aupi.HospitalManagement.Languages;
using NIIT.SaoBacDau.Aupi.HospitalManagement.Entities;
using NIIT.SaoBacDau.Aupi.HospitalManagement.BusinessLogic;

namespace NIIT.SaoBacDau.Aupi.HospitalManagement
{
    public partial class MedicalHistory : UserControl
    {
        private int typemedical;

        public MedicalHistory()
        {
            InitializeComponent();
        }

        public MedicalHistory(int typemedical)
        {
            InitializeComponent();
            this.typemedical = typemedical;
        }

        private void tbn_CloseMedicalHistory_Click(object sender, EventArgs e)
        {
            if (LibraryLanguages.CancelUserControl("Medical History") == true)
                ((Managements)this.Parent.Parent.Parent).ShowPatient(2,2);
        }

        private void MedicalHistory_Load(object sender, EventArgs e)
        {
            LoadTypeMedical();
            LoadMedicalHistoryDetails();
        }

        private void LoadMedicalHistoryDetails()
        {
            this.scr_MedicalHistory.Panel2.Controls.Clear();
            if (typemedical == 0)
            {
                TypeMedical1 tm1 = new TypeMedical1();
                tm1.Parent = this.scr_MedicalHistory.Panel2;
                tm1.Show();
            }
            else if (typemedical == 1)
            {
                TypeMedical2 tm2 = new TypeMedical2();
                tm2.Parent = this.scr_MedicalHistory.Panel2;
                tm2.Show();
            }
        }

        private void LoadTypeMedical()
        {
            List<Obj_TypeMedical> list = BL_TypeMedical.ListTypeMedical();
            for (int i = 0; i < list.Count; i++)
            {
                cbx_TypeMedical.Items.Add(list[i].NameDetails.ToString());
            }
            cbx_TypeMedical.SelectedIndex = 0;
        }

        private void cbx_TypeMedical_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.scr_MedicalHistory.Panel2.Controls.Clear();
            if (cbx_TypeMedical.SelectedIndex == 0)
            {
                TypeMedical1 tm1 = new TypeMedical1();
                tm1.Parent = this.scr_MedicalHistory.Panel2;
                tm1.Show();
            }
            else if (cbx_TypeMedical.SelectedIndex == 1)
            {
                TypeMedical2 tm1 = new TypeMedical2();
                tm1.Parent = this.scr_MedicalHistory.Panel2;
                tm1.Show();
            }
            else if (cbx_TypeMedical.SelectedIndex == 2)
            {
                TypeMedical3 tm1 = new TypeMedical3();
                tm1.Parent = this.scr_MedicalHistory.Panel2;
                tm1.Show();
            }
        }
    }
}
